package Day06;

import java.util.Arrays;
import java.util.Random;
import java.util.Scanner;

public class Practice2 {
    public static void main(String[] args) {
        double[]a=scores(5);
        for (int i=0;i<a.length;i++){
            System.out.print(a[i]+" ");
        }
        System.out.println();
        double d=avg(a);

        System.out.println("平均分为"+d);
    }

    public static double[] scores(int n){
        Scanner scan=new Scanner(System.in);
        double []a=new double[n];
        for (int i=0;i<a.length;i++){
            System.out.println("请输入第"+(i+1)+"位评委的评分");
            a[i]=scan.nextDouble();
        }
        return a;
    }
    public static double avg(double[]a){
        Arrays.sort(a);
        double sum=0,b=0;
        for (int i=1;i<a.length-1;i++){
            sum=sum+a[i];
        }
        b=sum/(a.length-2);
        return b;
    }
}
